<template>
    <div class="banner">
        <el-row>
            <el-col :span="15" :offset="3">
                <el-carousel :interval="5000" arrow="always">
                    <el-carousel-item v-for="item in banner_list">
                        <router-link :to="item.link">
                            <img :src="item.img" :alt="item.name">
                        </router-link>
                    </el-carousel-item>
                </el-carousel>
            </el-col>
            <el-col :span="4" :offset="0">
                <BannerRight/>
            </el-col>
        </el-row>
    </div>
</template>

<script>
    import BannerRight from "./BannerRight";

    export default {
        name: "Banner",
        components: {
            BannerRight
        },
        data() {
            return {
                banner_list: []
            }
        },
        created() {
            //当banner组件一创建，就向后台发请求，拿回轮播图数据
            this.$axios.get(this.$settings.base_url + '/home/banner/').then(response => {
                console.log(response.data);
                this.banner_list = response.data
            }).catch(error => {
            })
        },
    }
</script>

<style scoped>
    .el-carousel--horizontal {
        width: 950px;
        height: 100%;
        overflow-x: hidden;
    }

    .el-carousel__item h3 {
        color: #475669;
        font-size: 18px;
        width: 900px;
        opacity: 0.75;
        line-height: 300px;
        margin: 0;

    }

    .el-carousel__item:nth-child(2n) {
        background-color: #99a9bf;
    }

    .el-carousel__item:nth-child(2n+1) {
        background-color: #d3dce6;
    }

</style>